<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>创建课程</title>
	<link rel="stylesheet" href="css/addcourse_style.css">
	<link rel="stylesheet" href="css/left.css">
</head>
<body>	
<!-- 加载头部信息 -->
<?php
	include_once("header.php");
?>

<!-- 中间内容 -->
<div class="content clearfloat">
	<!-- 左边内容 -->
	<div class="left_content">
		<ul class="left_nav" id="left_ul">
			<li><a href="notice.php" class="li_a">
				<span class="text">
					<?php echo "<img src='images/notice.png' alt='图片' class='left_img1'";?>&nbsp;
					<span>动&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;态</span>
				</span>
				<canvas id="canvas_index1" width="18" height="48"></canvas>	
			</a></li>
			<li class="active_nav"><a href="addcourse.php" class="li_a">
				<span class="text">
					<?php echo "<img src='images/course.png' alt='图片' class='left_img2'";?>
					<span>创建课程</span>
				</span>
				<canvas id="canvas_index2" width="18" height="48"></canvas>
			</a></li>
			<li><a href="mycourse.php" class="li_a">
				<span class="text">
					<?php echo "<img src='images/mycourse.png' alt='图片' class='left_img3'";?>
					<span>我的课程</span>
				</span>
				<canvas id="canvas_index3" width="18" height="48"></canvas>
			</a></li>
			<li><a href="checkbook1.php" class="li_a">
				<span class="text">
					<?php echo "<img src='images/correct.png' alt='图片' class='left_img4'";?>
					<span>批改作业</span>
				</span>
				<canvas id="canvas_index4" width="18" height="48"></canvas>
			</a></li>
			<li><a href="per_setup.php" class="li_a">
				<span class="text">
					<?php echo "<img src='images/setup.png' alt='图片' class='left_img6'";?>
					<span>个人设置</span>
				</span>
				<canvas id="canvas_index6" width="18" height="48"></canvas>
			</a></li>
		</ul>
	</div>

	<!-- 右边内容 -->
	<div class="center_content">
		<ul id="nav">
			<li class="active li_a1"><a href="#" class="clearfloat a_prohibit">
				<span class="text">
					<span class="number">01</span>
					<span>基本信息</span>
				</span>
				<canvas id="canvas1" width="14" height="34"></canvas>
			</a></li>
			<li class="li_a2"><a href="#" class="clearfloat a_prohibit">
				<canvas id="canvas2" width="14" height="34"></canvas>
				<span class="text">
					<span class="number">02</span>
					<span>课程详情</span>
				</span>
				<canvas id="canvas3" width="14" height="34"></canvas>
			</a></li>
			<li class="li_a3"><a href="#" class="clearfloat a_prohibit">
				<canvas id="canvas4" width="14" height="34"></canvas>
				<span class="text">
					<span class="number">03</span>
					<span>创建完成</span>
				</span>
			</a></li>
		</ul>

		<div class="center_info">
			<div class="content_title">
				<h4>基本信息</h4>
				<hr>
			</div>
			
			<div class="content_form">
				<form action="" method="post">
					一级学科<select name="one" id="one">
						<option value="计算机科学与技术">计算机科学与技术</option>
					</select><br/><br/>
					二级学科<select name="two" id="two">
						<option value="计算机系统结构">计算机系统结构</option>
						<option value="计算机应用技术">计算机应用技术</option>
						<option value="计算机软件与理论">计算机软件与理论</option>
					</select><br/><br/>
					课程名称 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<input type="text" name="name" class="text">
					<span class="color">*</span><br/><br/>
<?php 
if(isset($_COOKIE["tea_number"])) {
	$tea_number = $_COOKIE["tea_number"];

	$selectteachers = "select tea_phone,tea_email from teachers where tea_number='$tea_number'";
	
	include_once("database.php");
			
	$result = @mysql_query($selectteachers) or die("查询老师信息表失败：".mysql_error()."<br/>");

	$row = @mysql_fetch_array($result,MYSQL_ASSOC);
	$mobile = $row["tea_phone"];
	$email = $row["tea_email"];
}


echo 	<<<tea_html
					主讲老师手机&nbsp;&nbsp;&nbsp;&nbsp;
					<input type='text' name='mobile' class='text' value='{$mobile}'>
					<span class='color'>*</span><br/><br/>
					主讲老师邮箱&nbsp;&nbsp;&nbsp;&nbsp;
					<input type='text' name='email' class='text' value='{$email}'>
					<span class='color'>*</span><br/><br/>

					是否公开课程&nbsp;&nbsp;&nbsp;&nbsp;
					<input type="radio" name="course" value="是">是&nbsp;&nbsp;&nbsp;&nbsp;
					<input type="radio" name="course" value="否" checked="checked">否<br/><br/>

					<input type="submit" name="submit_down" value="点击下一步" class="btn active_btn">
					<input type="reset" name="reset" value="取消" class="btn">
				</form>
			</div>
		</div>
	</div>
tea_html;

// if($_POST["course"] == "是") {

// }
?>

	<!-- 右侧栏 -->
	<?php
		include_once("right_content.php");
	?>
</div>

<!-- 加载左边导航的样式 -->
<?php
	include_once("nav_style.php");
?>

<?php
echo <<<canvas
<script>
    //创建绘图容器
    var canvas1 = document.getElementById("canvas1");
    var canvas2 = document.getElementById("canvas2");
    var canvas3 = document.getElementById("canvas3");
    var canvas4 = document.getElementById("canvas4");
   
	var context1 = canvas1.getContext("2d");
	var context3 = canvas3.getContext("2d");

	//状态设置
	context1.moveTo(0, 0);
    context1.lineTo(0, 34);
   	context1.lineTo(14, 18);
    context1.lineTo(0, 0);
	context1.fillStyle = "#049fc7";  //设置填充颜色

	context3.moveTo(0, 0);
    context3.lineTo(0, 34);
   	context3.lineTo(14, 18);
    context3.lineTo(0, 0);
	context3.fillStyle = "#ddd";  //设置填充颜色

	//状态绘画
	context1.fill(); 
	context3.fill();
    

    function canvas_triangle2(canvas) {
		var context = canvas.getContext("2d");

		//状态设置
		context.moveTo(0, 0);
    	context.lineTo(0, 34);
   		context.lineTo(14, 18);
    	context.lineTo(0, 0);
		context.fillStyle = "#fff";  //设置填充颜色

		//状态绘画
		context.fill(); 
    }
   
 	canvas_triangle2(canvas2);
 	canvas_triangle2(canvas4);
</script>

canvas;
?>

<?php 
if(isset($_COOKIE["tea_number"])) {
	$tea_number = $_COOKIE["tea_number"];

	if(isset($_POST["submit_down"]) && $_POST["submit_down"] == "点击下一步") {

		if($_POST["name"] == NULL) {
			echo "<script>alert('课程名称不能为空！');</script>";
		} else {

			$one_subject = $_POST["one"];
			$two_subject = $_POST["two"];
			$course_name = $_POST["name"];
			$tea_phone = $_POST["mobile"];
			$tea_email = $_POST["email"];
			$open_course = $_POST["course"];
		
			$insertcourse = "insert into courses(tea_number,one_subject,two_subject,course_name,
				tea_phone,tea_email,open_course) values('$tea_number','$one_subject','$two_subject',
				'$course_name','$tea_phone','$tea_email','$open_course')";

			@mysql_query($insertcourse) or die("插入课程信息数据失败：".mysql_error()."<br/>");
			
			// if($_POST["course"] == "是") {

			// } else {
			// }

			echo "<script>";
			echo "{window.location='addcourse_details.php';}";
			echo "</script>";
		}
	}
}
	/*if(isset($_POST["submit"]) && $_POST["submit"] == "取消") {
		echo "<script>";
		echo "{window.location='index.php';}";
		echo "</script>";
	}*/
?>

<!-- 加载底部信息 -->
<?php
	include_once("footer.php");
?>
</body>
</html>